/*

     This file is part of glstart.

    glstart is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

    glstart is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along with Foobar. If not, see <https://www.gnu.org/licenses/>. 
*/

#ifndef BMP_READER_H
#define BMP_READER_H

#pragma pack(1)
typedef struct BMPHeader {
  unsigned char ID[2];
  unsigned int file_size;
  unsigned char unused[4];
  unsigned int pixel_offset;
} BMPHeader;

typedef struct DIBHeader {
  unsigned int header_size;
  unsigned int width;
  unsigned int height;
  unsigned short color_planes;
  unsigned short bits_per_pixel;
  unsigned int comp;
  unsigned int data_size;
  unsigned int pwidth;
  unsigned int pheight;
  unsigned int colors_count;
  unsigned int imp_colors_count;
} DIBHeader;

typedef struct BMPFile {
  BMPHeader bhdr;
  DIBHeader dhdr;
  unsigned char* data;
} BMPFile;
#pragma pop

BMPFile* loadBMPFile(char* fname);
void freeBMPFile(BMPFile* bmp_file);

#endif
